<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTableKfFsUser extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('fs_user', function (Blueprint $table) {
            $table->id();
            $table->string("userId", 11)->default("")->comment("飞书user_id");
            $table->string("name", 11)->default("")->comment("姓名");
            $table->string("nickname", 36)->default("")->comment("昵称");
            $table->string("email", 36)->default("")->comment("邮箱");
            $table->string("mobile", 11)->default("")->comment("手机号");
            $table->unsignedTinyInteger("gender")->default(0)->comment("性别");
            $table->string("avatar", 120)->default("")->comment("头像");


            $table->string("openId", 36)->default("")->comment("open_id");
            $table->string("unionId", 36)->default("")->comment("union_id");


            $table->unsignedTinyInteger("isFrozen")->default(0)->comment("是否暂停");
            $table->unsignedTinyInteger("isResigned")->default(0)->comment("是否离职");
            $table->unsignedTinyInteger("isActivated")->default(0)->comment("是否激活");
            $table->unsignedTinyInteger("isExited")->default(0)->comment("是否主动退出，主动退出一段时间后用户会自动转为已离职");
            $table->unsignedTinyInteger("isUnJoin")->default(0)->comment("是否未加入，需要用户自主确认才能加入团队");


            $table->unsignedInteger("joinTime")->default(0)->comment("入职时间");
            $table->unsignedTinyInteger("isTenantManager")->default(0)->comment("是否是租户超级管理员");
            $table->string("employeeNo", 36)->default("")->comment("工号");
            $table->unsignedTinyInteger("employeeType")->default(1)->comment("员工类型");
            $table->string("departmentId", 36)->default("0")->comment("部门id");
            $table->string("departmentName", 120)->default("")->comment("部门名称");
            $table->string("parentDepartmentId", 36)->default("0")->comment("父部门id");
            $table->string("jobTitle", 120)->default("")->comment("职位");

            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('updatedAt')->default(0)->comment('更新时间');
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}customers` COMMENT = '飞书通讯录用户信息'"); //表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('fs_user');
    }
}
